﻿<?
include("../Comm/Manage_err.php");
include("../Comm/Conn.php");
include("../Comm/pageft.php");
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Netsys网站管理系统</title>
<link href="../Style/Css.css" rel="stylesheet" type="text/css" />
<script language="javascript">
function CheckAll(form)  
{
  for (var i=0;i<form.elements.length;i++)    
  {
    var e = form.elements[i];
    if (e.name != 'chkall')
	e.checked = form.chkall.checked; 
  }
}
function CheckOne()
{   
	var   flag=false;   
	var   NID=document.getElementsByName("NID");   
	for(i=0;i<NID.length;i++)
	{   
		if (NID(i).checked)
		{   
			flag=true;   
			break;   
		}   
	}   
	if (!flag)   
	{     
	  alert('请至少选择一条记录！');
	  return false;   
	}      
}   
</script>
</head>
<body>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="10"></td>
  </tr>
</table>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="right_tittle">
  <tr>
    <td width="3"><img src="../images/r1.jpg" width="10" height="33" /></td>
    <td><img src="../images/current.jpg" width="9" height="9" /> 当前位置 &gt;&gt; 新闻管理
      | 新闻管理列表</td>
    <td width="10" align="right"><img src="../images/r3.jpg" width="10" height="33" /></td>
  </tr>
</table>
  <table width="98%" border="0" align="center" cellpadding="0" cellspacing="2" class="right_con">
    <tr>
      <td height="490" align="center" valign="top" bgcolor="#FFFFFF">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="5"></td>
        </tr>
      </table>
      <br />
    <form name="Search" action="" method="post">
    <table width="98%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CDD8DF" class="table_all" >
        <tr>
          <td height="40" align="left" bgcolor="#FFFFFF" style="padding-left:10px;">请输入关键字：
          <input type="text" name="KeyWord" id="KeyWord" />
          <input type="submit" name="button" id="button" value=" 开始检索 " /></td>
        </tr>
    </table>
    </form>
    <form name="MyForm" action="Netsys_Del.php" method="post">
    <table width="98%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CDD8DF" class="table_all" >
      <tr class="table_tittle">
        <td bgcolor="#FFFFFF">编号</td>
        <td bgcolor="#FFFFFF">标题</td>
        <td bgcolor="#FFFFFF">类型</td>
        <td bgcolor="#FFFFFF">首页推荐</td>
        <td bgcolor="#FFFFFF">发布时间</td>
        <td width="60" bgcolor="#FFFFFF">操作</td>
        <td bgcolor="#FFFFFF">选择</td>
      </tr>
<?php
             if($_POST['KeyWord']){
		     $sql="SELECT * FROM Netsys_News where NTitle like '%$_POST[KeyWord]%' order by NID desc";
		     }else{
             $sql="SELECT * FROM Netsys_News order by NID desc";
			 }

//取得总信息数
$result=mysql_query($sql);
$total=mysql_num_rows($result);
//调用pageft()，每页显示10条信息（使用默认的20时，可以省略此参数），使用本页URL（默认，所以省略掉）。
pageft($total,15);
//现在产生的全局变量就派上用场了：
$result=mysql_query($sql);
if($total!=0){
while($row=mysql_fetch_array($result)){
//（列表内容略）
?>
      <tr>
        <td bgcolor="#FFFFFF"><? echo $row['NID']; ?></td>
        <td bgcolor="#FFFFFF"><? echo $row['NTitle']; ?>(点击率：<font color="#FF0000"><? echo $row['NViews']; ?></font>)</td>
        <td bgcolor="#FFFFFF">
      <?   
             $rs="SELECT * FROM Netsys_News_Class where ClassID=".$row[ClassID]." order by ClassOrder Asc";
             $query=mysql_query($rs);
			 $num=mysql_num_rows($query);
			 if($num!=0){
             $ro=mysql_fetch_array($query);
             echo $ro['ClassName'];
  }
  else
  {
  echo "类别不存在";
}
?>		
		</td>
        <td bgcolor="#FFFFFF">
		<?
		if($row['NHome']==1){
		echo "<font color='#FF0000'>√</font>";
		}else{
		echo "×";
		}
		?>
		</td>
        <td bgcolor="#FFFFFF"><? echo $row['NTime']; ?></td>
        <td bgcolor="#FFFFFF"><a href="Netsys_Edit.php?NID=<? echo $row['NID']; ?>">修改</a></td>
        <td bgcolor="#FFFFFF"><input type="checkbox" name="NID" value="<? echo $row['NID']; ?>" style="border:0px;"></td>
      </tr>
<?
}
?>
    </table>
    <table width="200" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="35" align="center">
        <input type="checkbox" name="chkall" id="chkall" onClick="CheckAll(this.form);" style="border:0px;" />
        全选
        </td>
        <td align="center">
        <input type="image" src="../images/del_all.jpg" onClick="return CheckOne();" style="width:94px; height:20px; border:0px;" />
        </td>
      </tr>
    </table>
    <table width="98%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="30" align="center">
<?
echo $pagenav;
?>        </td>
      </tr>
    </table>
<?
}
else{
echo "<tr><td colspan='10' bgcolor='#FFFFFF'>暂无信息，敬请期待！</td></tr></table>";
}
?>
   </form>
   </td>
  </tr>
</table>
</body>
</html>